package com.dao;

import com.pojo.Account;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface AccountDao {
    @Select("select * from account where id = #{id}")
    Account findById(Integer id);

    //下面要模拟银行的转入和转出的功能
    //从固定的账户中转出金额
    @Update("update account set balance =balance - #{money} where id = #{accountId}")
    void outMoney(@Param("accountId") int accountId, @Param("money") int money);

    //从固定的账户中转出金额
    @Update("update account set balance = balance + #{money} where id = #{accountId}")
    void inMoney(@Param("accountId") int accountId,@Param("money") int money);

}
